<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/woniu/Public/X-admin/css/x-admin.css" media="all">
</head>
<body>
        <div class="x-body">
            <form class="layui-form layui-form-pane" action="" method="">
                <div class="layui-form-item">
                    <label class="layui-form-label">
                        发送人
                    </label>
                    <div class="layui-input-inline">
                       <input type="text" name="sender" id="sender" required  lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>

				<div class="layui-form-item">
				    <label class="layui-form-label">选择框</label>
				    <div class="layui-input-inline">
				      <select name="type" lay-verify="required" lay-filter="type">
				        <option value="">--请选择--</option>
				        <option value="1">转班</option>
				        <option value="2">转校区</option>
				        <option value="3">见习</option>
				        <option value="4">休学</option>
				        <option value="5">退学</option>
				      </select>
				    </div>				    
				 </div>

				<!-- 默认隐藏选择1转班显示出来 -->
				 <div class="layui-form-item" id="class" style="display:none" >
				 	<label class="layui-form-label">选择框</label>
				 	<div class="layui-input-inline">
				      <select name="types" lay-verify="required" lay-filter="class">
				        <?php if(is_array($list)): foreach($list as $key=>$row): ?><option value="<?php echo ($row['id']); ?>" <?php if($row['id'] == $nowclass): ?>disabled<?php endif; ?>><?php echo ($row['name']); ?></option><?php endforeach; endif; ?>
				      </select>
				    </div>
				 </div>
        <br>
				<div class="layui-form-item layui-form-text">
				    <label class="layui-form-label">原因</label>
				    <div class="layui-input-block">
				      <textarea id="desc" placeholder="请输入内容" class="layui-textarea"></textarea>
				    </div>
				</div>
        <div class="layui-form-item">
          <div class="layui-input-block" >
              <button class="layui-btn" lay-submit lay-filter="add" style="float:right; margin-right:390px;">申请</button>
          </div>
        </div>                           
      </form>
    </div>
  </body>
</html>
  
   <script src="/woniu/Public/X-admin/lib/layui/layui.js" charset="utf-8"></script>
   <script src="/woniu/Public/X-admin/js/x-layui.js" charset="utf-8"></script>
   <script>
        layui.use(['form','layer'], function(){
              $ = layui.jquery;
              var form = layui.form();
              layer = layui.layer;
              form.on("select(type)",function(data){					
              		if(data.value==1){
              			$("#class").removeAttr("style");
              		}else{
              			$("#class").attr("style","display:none");
              		}
              		typedata=data.value;
              	});

              classdata=<?php echo ($nowclass); ?>;
              form.on("select(class)",function(data){	
              		classdata=data.value;
              });
              
              //监听提交
              form.on('submit(add)', function(data){
                desc = $("#desc").val();
                $.post('/woniu/index.php/Home/Shift/insert',{type:typedata,newclass:classdata,desc:desc},function(data){
                    if(data=="1"){
                       layer.alert("添加成功", {icon: 6},function () {
                          // 获得frame索引
                          var index = parent.layer.getFrameIndex(window.name);
                          //关闭当前frame
                          parent.layer.close(index);
                          parent.reload();
                       });
                    }else{
                       layer.alert("添加失败", {icon: 6,time:2000},function () {
                            return false;
                       });
                    }
                });
                return false;
            });
        }); 
    </script>